package org.xx.armory.config.app;

import org.xx.armory.config.NamedSection;
import org.xx.armory.config.PropertiesSection;

import static org.xx.armory.commons.Validators.notBlank;

/**
 * 按照目录分类的配置项集合。
 */
public final class CategorySection
        extends PropertiesSection
        implements NamedSection {
    private String name;
    private boolean enabled;

    public CategorySection() {
        this.name = "";
        this.enabled = true;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getName() {
        return name;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void setName(
            String name
    ) {
        this.name = notBlank(name, "name").trim();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean isEnabled() {
        return this.enabled;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void setEnabled(
            boolean enabled
    ) {
        this.enabled = enabled;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final String toString() {
        return "Category{name=" + this.name + ",enabled=" + this.enabled + ",size=" + this.size() + "}";
    }
}
